package com.hadoop.code.rpc;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;
import org.apache.hadoop.ipc.Server;

/**
 * @author ruimeng
 * @create 2021-11-24 13:44
 *  RPC服务端代码
 **/
public class NameNodeRpcServer implements ClientProtocol {

        @Override
        public void makeDir(String path) {
            System.out.println("服务端："+path);
        }

    @Override
    public void say(String s) {
        System.out.println("say something 。。。");
    }

    public static void main(String[] args) throws Exception {
        Server server = new RPC.Builder(new Configuration())
                .setBindAddress("localhost")
                .setPort(9999)
                .setProtocol(ClientProtocol.class)
                .setInstance(new NameNodeRpcServer())
                .build();
//启动服务端
        server.start();
    }
}
